package uebung02_w;

import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;


public class SiftDeskriptorBuilder {

	BufferedImage orgimg;
	double theta;
	Point2D featloc;
	
	public SiftDeskriptorBuilder(Point2D featurelocation, int angle, BufferedImage image) {
		this.orgimg = image;
		this.theta = Math.toRadians(angle);
		this.featloc = featurelocation;

		Rectangle2D selection = new Rectangle2D.Double();
		
		Point2D center = new Point2D.Double();
		center.setLocation(orgimg.getWidth()/2, orgimg.getHeight()/2);
		
		double maxdist = Math.sqrt(128); // maximaler abstand von center = sqrt( (16/2)^2 )
		
		
		// verschiebung und rotation
		
		// ueber das 16x16 feld um den featurepoint laufen
		for (int x = -2; x<2; x++) { // 2x2(x4) pixelhorizontal
			for (int y = -2; y<2; y++) { // 2x2(x4) pixel vertikal
				selection.setFrame(x*4, y*4, 4, 4); // 
				
				
				
			} // end for x
		} // end for y
		
		
		
		
		
		// make 16x16 patch
		// rotate through angle
		// overlay image with rotated patch
		// check which imagepixelmids belong to patch
		
	} // END Constructor
	
	
	
	
	
	
	static double[] normalize(double[] v) {
		double sumofsquares = 0;
		for (int i = 0; i < v.length; i++) sumofsquares += v[i]*v[i];
		double norm = Math.sqrt(sumofsquares);
		for (int i = 0; i < v.length; i++) v[i] = v[i]/norm;
		return v;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

} // END class SiftDeskriptoBuilder
